package com.ruoyi.project.app.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.app.domain.AppCustomer;
import com.ruoyi.project.app.service.IAppCustomerService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 用户Controller
 * 
 * @author hry
 * @date 2020-10-15
 */
@RestController
@RequestMapping("/system/appCustomer")
public class AppCustomerController extends BaseController
{
    @Autowired
    private IAppCustomerService appCustomerService;

    /**
     * 查询用户列表
     */
    @PreAuthorize("@ss.hasPermi('system:appCustomer:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppCustomer appCustomer)
    {
        startPage();
        List<AppCustomer> list = appCustomerService.selectAppCustomerList(appCustomer);
        return getDataTable(list);
    }

    /**
     * 导出用户列表
     */
    @PreAuthorize("@ss.hasPermi('system:appCustomer:export')")
    @Log(title = "用户", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AppCustomer appCustomer)
    {
        List<AppCustomer> list = appCustomerService.selectAppCustomerList(appCustomer);
        ExcelUtil<AppCustomer> util = new ExcelUtil<AppCustomer>(AppCustomer.class);
        return util.exportExcel(list, "appCustomer");
    }

    /**
     * 获取用户详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:appCustomer:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(appCustomerService.selectAppCustomerById(id));
    }

    /**
     * 新增用户
     */
    @PreAuthorize("@ss.hasPermi('system:appCustomer:add')")
    @Log(title = "用户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppCustomer appCustomer)
    {
        return toAjax(appCustomerService.insertAppCustomer(appCustomer));
    }

    /**
     * 修改用户
     */
    @PreAuthorize("@ss.hasPermi('system:appCustomer:edit')")
    @Log(title = "用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppCustomer appCustomer)
    {
        return toAjax(appCustomerService.updateAppCustomer(appCustomer));
    }

    /**
     * 删除用户
     */
    @PreAuthorize("@ss.hasPermi('system:appCustomer:remove')")
    @Log(title = "用户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appCustomerService.deleteAppCustomerByIds(ids));
    }
}
